#include "processbar.h"
#include <stdlib.h>
#include <time.h>

#define FILESIZE (1024*1024*1024)

void download()
{
    srand(time(NULL)^1023);
    int total = FILESIZE;

    while(total)
    {
        usleep(10000);
        int one = rand()%(1024*1024);
        total -= one;
        if(total < 0) total = 0;

        int download = FILESIZE-total;
        double rate = download*100.0 / FILESIZE;

        //printf("download:%f%%\n",rate);
        
        process_flush(rate);
    }
}

int main()
{
    //process();
    download();
    printf("rand_max:%d\n",RAND_MAX);
    return 0;
}
